﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;


   public class ActorManager
    {
        private static ActorManager instance = new ActorManager();
        public string playerId = "";
        public static ActorManager Instance
        {
            get
            {
                return instance;
            }
        }
        private ActorManager() { }


       public Role role;
       private List<Actors> myActors;
        /// <summary>
        /// 创建Actor
        /// </summary>
        /// <param name="heroId">英雄ID</param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public Actors CreatActor(string heroId, long roleId)
        {
            Dict.DataModel.TableHero dh = Dict.DictDataManager.Instance.tableHeroDao.GetById(heroId);

            

            Actors actorData = new Actors();
            actorData.Init(dh, 0);
            actorData.id = roleId;

            return actorData;
        }

        public void InitActor()
        {
            role = new Role();
            role.nickName = "梅超风";
            role.pid = 1;
            role.styleId = 1;
            role.zoneId = "1";

            myActors = new List<Actors>();
            //遍历英雄列表，都显示出来
            foreach (var item in Dict.DictDataManager.Instance.tableHeroDao.CacheList)  
            {
                myActors.Add(CreatActor(item.id, role.pid));
            }


            for (var i = 0; i < 4; i++)
            {
                myActors[i].formationPositionId = i + 1;
                
            }
        }

       /// <summary>
       /// 通过位置获取玩家的Actor
       /// </summary>
       /// <param name="index"></param>
       /// <returns></returns>
    public Actors GetMyActorByPostion(int index)
    {
        foreach (var item in myActors)
        {
            if (item.formationPositionId == index)
            {
                return item;
            }
        }
        return null;
    }

    public List<Actors> GetActor() 
    {
        if (myActors == null)
        {
            return null;
        }
        else
        {
            return myActors;
        }
    }
}

